import pandas as pd

# 读取CSV文件
file_path = r'D:\python1\doc\boss直聘数据.csv'

try:
    # 尝试读取CSV文件
    df = pd.read_csv(file_path, encoding='utf-8')
    print("文件读取成功")
    print(f"数据形状: {df.shape}")
    print("\n前10行数据:")
    print(df.head(10))
    print("\n列名:")
    print(df.columns.tolist())
    print("\n数据类型:")
    print(df.dtypes)
    print("\n缺失值统计:")
    print(df.isnull().sum())
    print("\n数值列统计:")
    print(df.describe())
except Exception as e:
    print(f"读取文件时出错: {e}")
    # 尝试其他编码
    try:
        df = pd.read_csv(file_path, encoding='gbk')
        print("使用GBK编码读取成功")
        print(f"数据形状: {df.shape}")
        print("\n前10行数据:")
        print(df.head(10))
        print("\n列名:")
        print(df.columns.tolist())
        print("\n数据类型:")
        print(df.dtypes)
        print("\n缺失值统计:")
        print(df.isnull().sum())
        print("\n数值列统计:")
        print(df.describe())
    except Exception as e2:
        print(f"使用GBK编码也失败: {e2}")